﻿using System.Diagnostics.CodeAnalysis;

namespace CoreModule
{
    /// <summary>
    /// 每天时段 保留一个
    /// </summary>
    public class BloodGlucoseMeasurementInfoEqualityComparer : IEqualityComparer<BloodGlucoseMeasurementInfo>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public bool Equals([AllowNull] BloodGlucoseMeasurementInfo x, [AllowNull] BloodGlucoseMeasurementInfo y)
        {
            if (x==null || y==null) return false;
            return x.MeasurementTime.Date == y.MeasurementTime.Date && x.BloodGlucosePeriod == y.BloodGlucosePeriod;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int GetHashCode([DisallowNull] BloodGlucoseMeasurementInfo obj)
        {
            return (obj.MeasurementTime.ToString("yyyy-MM-dd") + obj.BloodGlucosePeriod.ToString()).GetHashCode();
        }
    }
}
